<!DOCTYPE html>


  <html class="dark page-post">


<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>eslint配置文件详解 | Poetry&#39;s Blog</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="eslint,代码风格,">
  

  <meta name="description" content="ESLint是一个Javascript静态检查工具，它可以帮你养成良好的编程习惯  &amp;#123;    // 环境定义了预定义的全局变量。    &quot;env&quot;: &amp;#123;        //环境定义了预定义的全局变量。更多在官网查看        &quot;browser&quot;: true,        &quot;node&quot;: true,        &quot;commonjs&quot;: true,        &quot;amd">
<meta name="keywords" content="eslint,代码风格">
<meta property="og:type" content="article">
<meta property="og:title" content="eslint配置文件详解">
<meta property="og:url" content="http://blog.poetries.top/2018/11/23/eslint-conf-info/index.html">
<meta property="og:site_name" content="Poetry&#39;s Blog">
<meta property="og:description" content="ESLint是一个Javascript静态检查工具，它可以帮你养成良好的编程习惯  &amp;#123;    // 环境定义了预定义的全局变量。    &quot;env&quot;: &amp;#123;        //环境定义了预定义的全局变量。更多在官网查看        &quot;browser&quot;: true,        &quot;node&quot;: true,        &quot;commonjs&quot;: true,        &quot;amd">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-08-15T04:25:31.906Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="eslint配置文件详解">
<meta name="twitter:description" content="ESLint是一个Javascript静态检查工具，它可以帮你养成良好的编程习惯  &amp;#123;    // 环境定义了预定义的全局变量。    &quot;env&quot;: &amp;#123;        //环境定义了预定义的全局变量。更多在官网查看        &quot;browser&quot;: true,        &quot;node&quot;: true,        &quot;commonjs&quot;: true,        &quot;amd">

  

  
    <link rel="icon" href="/favicon.ico">
  

  <link href="/css/styles.css?v=c114cbeddx" rel="stylesheet">
<link href="/css/other.css?v=c114cbeddx" rel="stylesheet">


  
    <link rel="stylesheet" href="/css/personal-style.css">
  

  

  
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?40b1f89aa80f2527b3db779c6898c879";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>


  
  <script type="text/javascript">
	(function(){
	    var bp = document.createElement('script');
	    var curProtocol = window.location.protocol.split(':')[0];
	    if (curProtocol === 'https') {
	        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
	    }
	    else {
	        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
	    }
	    var s = document.getElementsByTagName("script")[0];
	    s.parentNode.insertBefore(bp, s);
	})();
  </script>



  
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
  

  <!-- 聊天系统 -->
  
    
   <link type="text/css" rel="stylesheet" href="/renxi/default.css">
   <style>
      #modal {
        position: static !important;
      }
      .filter {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #fe5757;
        animation: colorChange 30s ease-in-out infinite;
        animation-fill-mode: both;
        mix-blend-mode: overlay;
      }
  
      @keyframes colorChange {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: .9;
        }
      }
   </style>
</head>
</html>
<body>
  
  
    <span id="toolbox-mobile" class="toolbox-mobile">导航</span>
  

  <div class="post-header CENTER">
   
  <div class="toolbox">
    <a class="toolbox-entry" href="/">
      <span class="toolbox-entry-text">导航</span>
      <i class="icon-angle-down"></i>
      <i class="icon-home"></i>
    </a>
    <ul class="list-toolbox">
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/archives/"
            rel="noopener noreferrer"
            target="_self"
            >
            博客
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/categories/"
            rel="noopener noreferrer"
            target="_self"
            >
            分类
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/tags/"
            rel="noopener noreferrer"
            target="_self"
            >
            标签
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/search/"
            rel="noopener noreferrer"
            target="_self"
            >
            搜索
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/link/"
            rel="noopener noreferrer"
            target="_self"
            >
            友链
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/about/"
            rel="noopener noreferrer"
            target="_self"
            >
            关于
          </a>
        </li>
      
    </ul>
  </div>


</div>





<div class="content content-post CENTER">
   <!-- canvas 彩带 -->
<canvas id="evanyou" width="1302" height="678" style="position: fixed;width: 100%;height: 100%;top: 0;left:0;z-index:-1;"></canvas>

<article id="post-eslint-conf-info" class="article article-type-post" itemprop="blogPost">
  <header class="article-header" style="position:relative;">
    <h1 class="post-title">eslint配置文件详解</h1>

    <div class="article-meta">
      <span>
        <i class="icon-calendar"></i>
        <span>2018.11.23</span>
      </span>

      
        <span class="article-author">
          <i class="icon-user"></i>
          <span>Poetry</span>
        </span>
      

      
  <span class="article-category">
    <i class="icon-list"></i>
    <a class="article-category-link" href="/categories/Front-End/">Front-End</a>
  </span>



      

      
      <i class="fa fa-eye"></i> 
        <span id="busuanzi_container_page_pv">
           &nbsp热度 <span id="busuanzi_value_page_pv">
           <i class="fa fa-spinner fa-spin"></i></span>℃
        </span>
      
      
       
          <span class="post-count">
            <i class="fa fa-file-word-o"></i>&nbsp
            <span>字数统计 4.4k字</span>
          </span>

          <span class="post-count">
            <i class="fa fa-columns"></i>&nbsp
            <span>阅读时长 18分</span>
          </span>
      
      
    </div>

    <i class="iconfont" id="toc-eye" style="display:inline-block;color:#b36619;position:absolute;top:0;right:0;cursor:pointer;
    font-size: 24px;">&#xe61c;</i>

  </header>

  <div class="article-content">
    
      <div id="container">
        <blockquote>
<p><code>ESLint</code>是一个<code>Javascript</code>静态检查工具，它可以帮你养成良好的编程习惯</p>
</blockquote>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="comment">// 环境定义了预定义的全局变量。</span></span><br><span class="line">    <span class="string">"env"</span>: &#123;</span><br><span class="line">        <span class="comment">//环境定义了预定义的全局变量。更多在官网查看</span></span><br><span class="line">        <span class="string">"browser"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="string">"node"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="string">"commonjs"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="string">"amd"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="string">"es6"</span>: <span class="literal">true</span>,</span><br><span class="line">        <span class="string">"mocha"</span>: <span class="literal">true</span></span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="comment">// JavaScript 语言选项</span></span><br><span class="line">    <span class="string">"parserOptions"</span>: &#123;</span><br><span class="line">        <span class="comment">// ECMAScript 版本</span></span><br><span class="line">        <span class="string">"ecmaVersion"</span>: <span class="number">6</span>,</span><br><span class="line">        <span class="string">"sourceType"</span>: <span class="string">"module"</span>, <span class="comment">//设置为 "script" (默认) 或 "module"（如果你的代码是 ECMAScript 模块)。</span></span><br><span class="line">        <span class="comment">//想使用的额外的语言特性:</span></span><br><span class="line">        <span class="string">"ecmaFeatures"</span>: &#123;</span><br><span class="line">            <span class="comment">// 允许在全局作用域下使用 return 语句</span></span><br><span class="line">            <span class="string">"globalReturn"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="comment">// impliedStric</span></span><br><span class="line">            <span class="string">"impliedStrict"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="comment">// 启用 JSX</span></span><br><span class="line">            <span class="string">"jsx"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="string">"modules"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="comment">//-----让eslint支持 JSX start</span></span><br><span class="line">    <span class="string">"plugins"</span>: [</span><br><span class="line">        <span class="string">"react"</span></span><br><span class="line">    ],</span><br><span class="line">    <span class="string">"extends"</span>: [</span><br><span class="line">        <span class="string">"eslint:recommended"</span>,</span><br><span class="line">        <span class="string">"plugin:react/recommended"</span></span><br><span class="line">    ],</span><br><span class="line">    <span class="comment">//-----让eslint支持 JSX end</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * "off" 或 0 - 关闭规则</span></span><br><span class="line"><span class="comment">     * "warn" 或 1 - 开启规则，使用警告级别的错误：warn (不会导致程序退出),</span></span><br><span class="line"><span class="comment">     * "error" 或 2 - 开启规则，使用错误级别的错误：error (当被触发的时候，程序会退出)</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="string">"rules"</span>: &#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">////////////////</span></span><br><span class="line">        <span class="comment">// 可能的错误 //</span></span><br><span class="line">        <span class="comment">////////////////</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 禁止条件表达式中出现赋值操作符</span></span><br><span class="line">        <span class="string">"no-cond-assign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用 console</span></span><br><span class="line">        <span class="string">"no-console"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止在条件中使用常量表达式</span></span><br><span class="line">        <span class="comment">// if (false) &#123;</span></span><br><span class="line">        <span class="comment">// doSomethingUnfinished();</span></span><br><span class="line">        <span class="comment">// &#125; //cuowu</span></span><br><span class="line">        <span class="string">"no-constant-condition"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在正则表达式中使用控制字符 ：new RegExp("\x1f")</span></span><br><span class="line">        <span class="string">"no-control-regex"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 数组和对象键值对最后一个逗号， never参数：不能带末尾的逗号, always参数：必须带末尾的逗号，</span></span><br><span class="line">        <span class="comment">// always-multiline：多行模式必须带逗号，单行模式不能带逗号</span></span><br><span class="line">        <span class="string">"comma-dangle"</span>: [<span class="number">1</span>, <span class="string">"never"</span>],</span><br><span class="line">        <span class="comment">// 禁用 debugger</span></span><br><span class="line">        <span class="string">"no-debugger"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止 function 定义中出现重名参数</span></span><br><span class="line">        <span class="string">"no-dupe-args"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止对象字面量中出现重复的 key</span></span><br><span class="line">        <span class="string">"no-dupe-keys"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止重复的 case 标签</span></span><br><span class="line">        <span class="string">"no-duplicate-case"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止空语句块</span></span><br><span class="line">        <span class="string">"no-empty"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在正则表达式中使用空字符集 (/^abc[]/)</span></span><br><span class="line">        <span class="string">"no-empty-character-class"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止对 catch 子句的参数重新赋值</span></span><br><span class="line">        <span class="string">"no-ex-assign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的布尔转换</span></span><br><span class="line">        <span class="string">"no-extra-boolean-cast"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的括号 //(a * b) + c;//报错</span></span><br><span class="line">        <span class="string">"no-extra-parens"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的分号</span></span><br><span class="line">        <span class="string">"no-extra-semi"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止对 function 声明重新赋值</span></span><br><span class="line">        <span class="string">"no-func-assign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在嵌套的块中出现 function 或 var 声明</span></span><br><span class="line">        <span class="string">"no-inner-declarations"</span>: [<span class="number">2</span>, <span class="string">"functions"</span>],</span><br><span class="line">        <span class="comment">// 禁止 RegExp 构造函数中无效的正则表达式字符串</span></span><br><span class="line">        <span class="string">"no-invalid-regexp"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在字符串和注释之外不规则的空白</span></span><br><span class="line">        <span class="string">"no-irregular-whitespace"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在 in 表达式中出现否定的左操作数</span></span><br><span class="line">        <span class="string">"no-negated-in-lhs"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止把全局对象 (Math 和 JSON) 作为函数调用 错误：var math = Math();</span></span><br><span class="line">        <span class="string">"no-obj-calls"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止直接使用 Object.prototypes 的内置属性</span></span><br><span class="line">        <span class="string">"no-prototype-builtins"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止正则表达式字面量中出现多个空格</span></span><br><span class="line">        <span class="string">"no-regex-spaces"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用稀疏数组</span></span><br><span class="line">        <span class="string">"no-sparse-arrays"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止出现令人困惑的多行表达式</span></span><br><span class="line">        <span class="string">"no-unexpected-multiline"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在return、throw、continue 和 break语句之后出现不可达代码</span></span><br><span class="line">        <span class="string">"no-unreachable"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 要求使用 isNaN() 检查 NaN</span></span><br><span class="line">        <span class="string">"use-isnan"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 强制使用有效的 JSDoc 注释</span></span><br><span class="line">        <span class="string">"valid-jsdoc"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 强制 typeof 表达式与有效的字符串进行比较</span></span><br><span class="line">        <span class="comment">// typeof foo === "undefimed" 错误</span></span><br><span class="line">        <span class="string">"valid-typeof"</span>: <span class="number">2</span>,</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line">        <span class="comment">// 最佳实践 //</span></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 定义对象的set存取器属性时，强制定义get</span></span><br><span class="line">        <span class="string">"accessor-pairs"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 强制数组方法的回调函数中有 return 语句</span></span><br><span class="line">        <span class="string">"array-callback-return"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制把变量的使用限制在其定义的作用域范围内</span></span><br><span class="line">        <span class="string">"block-scoped-var"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 限制圈复杂度，也就是类似if else能连续接多少个</span></span><br><span class="line">        <span class="string">"complexity"</span>: [<span class="number">2</span>, <span class="number">9</span>],</span><br><span class="line">        <span class="comment">// 要求 return 语句要么总是指定返回的值，要么不指定</span></span><br><span class="line">        <span class="string">"consistent-return"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制所有控制语句使用一致的括号风格</span></span><br><span class="line">        <span class="string">"curly"</span>: [<span class="number">2</span>, <span class="string">"all"</span>],</span><br><span class="line">        <span class="comment">// switch 语句强制 default 分支，也可添加 // no default 注释取消此次警告</span></span><br><span class="line">        <span class="string">"default-case"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 强制object.key 中 . 的位置，参数:</span></span><br><span class="line">        <span class="comment">// property，'.'号应与属性在同一行</span></span><br><span class="line">        <span class="comment">// object, '.' 号应与对象名在同一行</span></span><br><span class="line">        <span class="string">"dot-location"</span>: [<span class="number">2</span>, <span class="string">"property"</span>],</span><br><span class="line">        <span class="comment">// 强制使用.号取属性</span></span><br><span class="line">        <span class="comment">// 参数： allowKeywords：true 使用保留字做属性名时，只能使用.方式取属性</span></span><br><span class="line">        <span class="comment">// false 使用保留字做属性名时, 只能使用[]方式取属性 e.g [2, &#123;"allowKeywords": false&#125;]</span></span><br><span class="line">        <span class="comment">// allowPattern: 当属性名匹配提供的正则表达式时，允许使用[]方式取值,否则只能用.号取值 e.g [2, &#123;"allowPattern": "^[a-z]+(_[a-z]+)+$"&#125;]</span></span><br><span class="line">        <span class="string">"dot-notation"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"allowKeywords"</span>: <span class="literal">false</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 使用 === 替代 == allow-null允许null和undefined==</span></span><br><span class="line">        <span class="string">"eqeqeq"</span>: [<span class="number">2</span>, <span class="string">"allow-null"</span>],</span><br><span class="line">        <span class="comment">// 要求 for-in 循环中有一个 if 语句</span></span><br><span class="line">        <span class="string">"guard-for-in"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用 alert、confirm 和 prompt</span></span><br><span class="line">        <span class="string">"no-alert"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 arguments.caller 或 arguments.callee</span></span><br><span class="line">        <span class="string">"no-caller"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许在 case 子句中使用词法声明</span></span><br><span class="line">        <span class="string">"no-case-declarations"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止除法操作符显式的出现在正则表达式开始的位置</span></span><br><span class="line">        <span class="string">"no-div-regex"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止 if 语句中有 return 之后有 else</span></span><br><span class="line">        <span class="string">"no-else-return"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止出现空函数.如果一个函数包含了一条注释，它将不会被认为有问题。</span></span><br><span class="line">        <span class="string">"no-empty-function"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止使用空解构模式no-empty-pattern</span></span><br><span class="line">        <span class="string">"no-empty-pattern"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在没有类型检查操作符的情况下与 null 进行比较</span></span><br><span class="line">        <span class="string">"no-eq-null"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 禁用 eval()</span></span><br><span class="line">        <span class="string">"no-eval"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止扩展原生类型</span></span><br><span class="line">        <span class="string">"no-extend-native"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的 .bind() 调用</span></span><br><span class="line">        <span class="string">"no-extra-bind"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用不必要的标签</span></span><br><span class="line">        <span class="string">"no-extra-label:"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止 case 语句落空</span></span><br><span class="line">        <span class="string">"no-fallthrough"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止数字字面量中使用前导和末尾小数点</span></span><br><span class="line">        <span class="string">"no-floating-decimal"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止使用短符号进行类型转换(!!fOO)</span></span><br><span class="line">        <span class="string">"no-implicit-coercion"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止在全局范围内使用 var 和命名的 function 声明</span></span><br><span class="line">        <span class="string">"no-implicit-globals"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 禁止使用类似 eval() 的方法</span></span><br><span class="line">        <span class="string">"no-implied-eval"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止 this 关键字出现在类和类对象之外</span></span><br><span class="line">        <span class="string">"no-invalid-this"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 __iterator__ 属性</span></span><br><span class="line">        <span class="string">"no-iterator"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用标签语句</span></span><br><span class="line">        <span class="string">"no-labels"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用不必要的嵌套块</span></span><br><span class="line">        <span class="string">"no-lone-blocks"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在循环中出现 function 声明和表达式</span></span><br><span class="line">        <span class="string">"no-loop-func"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 禁用魔术数字(3.14什么的用常量代替)</span></span><br><span class="line">        <span class="string">"no-magic-numbers"</span>: [<span class="number">1</span>, &#123;</span><br><span class="line">            <span class="string">"ignore"</span>: [<span class="number">0</span>, <span class="number">-1</span>, <span class="number">1</span>]</span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 禁止使用多个空格</span></span><br><span class="line">        <span class="string">"no-multi-spaces"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止使用多行字符串，在 JavaScript 中，可以在新行之前使用斜线创建多行字符串</span></span><br><span class="line">        <span class="string">"no-multi-str"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止对原生对象赋值</span></span><br><span class="line">        <span class="string">"no-native-reassign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在非赋值或条件语句中使用 new 操作符</span></span><br><span class="line">        <span class="string">"no-new"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止对 Function 对象使用 new 操作符</span></span><br><span class="line">        <span class="string">"no-new-func"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止对 String，Number 和 Boolean 使用 new 操作符</span></span><br><span class="line">        <span class="string">"no-new-wrappers"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用八进制字面量</span></span><br><span class="line">        <span class="string">"no-octal"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止在字符串中使用八进制转义序列</span></span><br><span class="line">        <span class="string">"no-octal-escape"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许对 function 的参数进行重新赋值</span></span><br><span class="line">        <span class="string">"no-param-reassign"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 __proto__ 属性</span></span><br><span class="line">        <span class="string">"no-proto"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止使用 var 多次声明同一变量</span></span><br><span class="line">        <span class="string">"no-redeclare"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用指定的通过 require 加载的模块</span></span><br><span class="line">        <span class="string">"no-return-assign"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止使用 javascript: url</span></span><br><span class="line">        <span class="string">"no-script-url"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止自我赋值</span></span><br><span class="line">        <span class="string">"no-self-assign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止自身比较</span></span><br><span class="line">        <span class="string">"no-self-compare"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用逗号操作符</span></span><br><span class="line">        <span class="string">"no-sequences"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止抛出非异常字面量</span></span><br><span class="line">        <span class="string">"no-throw-literal"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用一成不变的循环条件</span></span><br><span class="line">        <span class="string">"no-unmodified-loop-condition"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止出现未使用过的表达式</span></span><br><span class="line">        <span class="string">"no-unused-expressions"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用未使用过的标签</span></span><br><span class="line">        <span class="string">"no-unused-labels"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的 .call() 和 .apply()</span></span><br><span class="line">        <span class="string">"no-useless-call"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的字符串字面量或模板字面量的连接</span></span><br><span class="line">        <span class="string">"no-useless-concat"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用不必要的转义字符</span></span><br><span class="line">        <span class="string">"no-useless-escape"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 void 操作符</span></span><br><span class="line">        <span class="string">"no-void"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止在注释中使用特定的警告术语</span></span><br><span class="line">        <span class="string">"no-warning-comments"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 with 语句</span></span><br><span class="line">        <span class="string">"no-with"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 强制在parseInt()使用基数参数</span></span><br><span class="line">        <span class="string">"radix"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 要求所有的 var 声明出现在它们所在的作用域顶部</span></span><br><span class="line">        <span class="string">"vars-on-top"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求 IIFE 使用括号括起来</span></span><br><span class="line">        <span class="string">"wrap-iife"</span>: [<span class="number">2</span>, <span class="string">"any"</span>],</span><br><span class="line">        <span class="comment">// 要求或禁止 “Yoda” 条件</span></span><br><span class="line">        <span class="string">"yoda"</span>: [<span class="number">2</span>, <span class="string">"never"</span>],</span><br><span class="line">        <span class="comment">// 要求或禁止使用严格模式指令</span></span><br><span class="line">        <span class="string">"strict"</span>: <span class="number">0</span>,</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line">        <span class="comment">// 变量声明 //</span></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 要求或禁止 var 声明中的初始化(初值)</span></span><br><span class="line">        <span class="string">"init-declarations"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 不允许 catch 子句的参数与外层作用域中的变量同名</span></span><br><span class="line">        <span class="string">"no-catch-shadow"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止删除变量</span></span><br><span class="line">        <span class="string">"no-delete-var"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许标签与变量同名</span></span><br><span class="line">        <span class="string">"no-label-var"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用特定的全局变量</span></span><br><span class="line">        <span class="string">"no-restricted-globals"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止 var 声明 与外层作用域的变量同名</span></span><br><span class="line">        <span class="string">"no-shadow"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止覆盖受限制的标识符</span></span><br><span class="line">        <span class="string">"no-shadow-restricted-names"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用未声明的变量，除非它们在 /*global */ 注释中被提到</span></span><br><span class="line">        <span class="string">"no-undef"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止将变量初始化为 undefined</span></span><br><span class="line">        <span class="string">"no-undef-init"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止将 undefined 作为标识符</span></span><br><span class="line">        <span class="string">"no-undefined"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止出现未使用过的变量</span></span><br><span class="line">        <span class="string">"no-unused-vars"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"vars"</span>: <span class="string">"all"</span>,</span><br><span class="line">            <span class="string">"args"</span>: <span class="string">"none"</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 不允许在变量定义之前使用它们</span></span><br><span class="line">        <span class="string">"no-use-before-define"</span>: <span class="number">0</span>,</span><br><span class="line"></span><br><span class="line">        <span class="comment">//////////////////////////</span></span><br><span class="line">        <span class="comment">// Node.js and CommonJS //</span></span><br><span class="line">        <span class="comment">//////////////////////////</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// require return statements after callbacks</span></span><br><span class="line">        <span class="string">"callback-return"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求 require() 出现在顶层模块作用域中</span></span><br><span class="line">        <span class="string">"global-require"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 要求回调函数中有容错处理</span></span><br><span class="line">        <span class="string">"handle-callback-err"</span>: [<span class="number">2</span>, <span class="string">"^(err|error)$"</span>],</span><br><span class="line">        <span class="comment">// 禁止混合常规 var 声明和 require 调用</span></span><br><span class="line">        <span class="string">"no-mixed-requires"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止调用 require 时使用 new 操作符</span></span><br><span class="line">        <span class="string">"no-new-require"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止对 __dirname 和 __filename进行字符串连接</span></span><br><span class="line">        <span class="string">"no-path-concat"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 process.env</span></span><br><span class="line">        <span class="string">"no-process-env"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用 process.exit()</span></span><br><span class="line">        <span class="string">"no-process-exit"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用同步方法</span></span><br><span class="line">        <span class="string">"no-sync"</span>: <span class="number">0</span>,</span><br><span class="line"></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line">        <span class="comment">// 风格指南 //</span></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 指定数组的元素之间要以空格隔开(, 后面)， never参数：[ 之前和 ] 之后不能带空格，always参数：[ 之前和 ] 之后必须带空格</span></span><br><span class="line">        <span class="string">"array-bracket-spacing"</span>: [<span class="number">2</span>, <span class="string">"never"</span>],</span><br><span class="line">        <span class="comment">// 禁止或强制在单行代码块中使用空格(禁用)</span></span><br><span class="line">        <span class="string">"block-spacing"</span>: [<span class="number">1</span>, <span class="string">"never"</span>],</span><br><span class="line">        <span class="comment">//强制使用一致的缩进 第二个参数为 "tab" 时，会使用tab，</span></span><br><span class="line">        <span class="comment">// if while function 后面的&#123;必须与if在同一行，java风格。</span></span><br><span class="line">        <span class="string">"brace-style"</span>: [<span class="number">2</span>, <span class="string">"1tbs"</span>, &#123;</span><br><span class="line">            <span class="string">"allowSingleLine"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 双峰驼命名格式</span></span><br><span class="line">        <span class="string">"camelcase"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 控制逗号前后的空格</span></span><br><span class="line">        <span class="string">"comma-spacing"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"before"</span>: <span class="literal">false</span>,</span><br><span class="line">            <span class="string">"after"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 控制逗号在行尾出现还是在行首出现 (默认行尾)</span></span><br><span class="line">        <span class="comment">// http://eslint.org/docs/rules/comma-style</span></span><br><span class="line">        <span class="string">"comma-style"</span>: [<span class="number">2</span>, <span class="string">"last"</span>],</span><br><span class="line">        <span class="comment">//"SwitchCase" (默认：0) 强制 switch 语句中的 case 子句的缩进水平</span></span><br><span class="line">        <span class="comment">// 以方括号取对象属性时，[ 后面和 ] 前面是否需要空格, 可选参数 never, always</span></span><br><span class="line">        <span class="string">"computed-property-spacing"</span>: [<span class="number">2</span>, <span class="string">"never"</span>],</span><br><span class="line">        <span class="comment">// 用于指统一在回调函数中指向this的变量名，箭头函数中的this已经可以指向外层调用者，应该没卵用了</span></span><br><span class="line">        <span class="comment">// e.g [0,"that"] 指定只能 var that = this. that不能指向其他任何值，this也不能赋值给that以外的其他值</span></span><br><span class="line">        <span class="string">"consistent-this"</span>: [<span class="number">1</span>, <span class="string">"that"</span>],</span><br><span class="line">        <span class="comment">// 强制使用命名的 function 表达式</span></span><br><span class="line">        <span class="string">"func-names"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 文件末尾强制换行</span></span><br><span class="line">        <span class="string">"eol-last"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="string">"indent"</span>: [<span class="number">2</span>, <span class="number">4</span>, &#123;</span><br><span class="line">            <span class="string">"SwitchCase"</span>: <span class="number">1</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 强制在对象字面量的属性中键和值之间使用一致的间距</span></span><br><span class="line">        <span class="string">"key-spacing"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"beforeColon"</span>: <span class="literal">false</span>,</span><br><span class="line">            <span class="string">"afterColon"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 强制使用一致的换行风格</span></span><br><span class="line">        <span class="string">"linebreak-style"</span>: [<span class="number">1</span>, <span class="string">"unix"</span>],</span><br><span class="line">        <span class="comment">// 要求在注释周围有空行 ( 要求在块级注释之前有一空行)</span></span><br><span class="line">        <span class="string">"lines-around-comment"</span>: [<span class="number">1</span>, &#123;</span><br><span class="line">            <span class="string">"beforeBlockComment"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 强制一致地使用函数声明或函数表达式，方法定义风格，参数：</span></span><br><span class="line">        <span class="comment">// declaration: 强制使用方法声明的方式，function f()&#123;&#125; e.g [2, "declaration"]</span></span><br><span class="line">        <span class="comment">// expression：强制使用方法表达式的方式，var f = function() &#123;&#125; e.g [2, "expression"]</span></span><br><span class="line">        <span class="comment">// allowArrowFunctions: declaration风格中允许箭头函数。 e.g [2, "declaration", &#123; "allowArrowFunctions": true &#125;]</span></span><br><span class="line">        <span class="string">"func-style"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制回调函数最大嵌套深度 5层</span></span><br><span class="line">        <span class="string">"max-nested-callbacks"</span>: [<span class="number">1</span>, <span class="number">5</span>],</span><br><span class="line">        <span class="comment">// 禁止使用指定的标识符</span></span><br><span class="line">        <span class="string">"id-blacklist"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制标识符的最新和最大长度</span></span><br><span class="line">        <span class="string">"id-length"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求标识符匹配一个指定的正则表达式</span></span><br><span class="line">        <span class="string">"id-match"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制在 JSX 属性中一致地使用双引号或单引号</span></span><br><span class="line">        <span class="string">"jsx-quotes"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制在关键字前后使用一致的空格 (前后腰需要)</span></span><br><span class="line">        <span class="string">"keyword-spacing"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 强制一行的最大长度</span></span><br><span class="line">        <span class="string">"max-len"</span>: [<span class="number">1</span>, <span class="number">200</span>],</span><br><span class="line">        <span class="comment">// 强制最大行数</span></span><br><span class="line">        <span class="string">"max-lines"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制 function 定义中最多允许的参数数量</span></span><br><span class="line">        <span class="string">"max-params"</span>: [<span class="number">1</span>, <span class="number">7</span>],</span><br><span class="line">        <span class="comment">// 强制 function 块最多允许的的语句数量</span></span><br><span class="line">        <span class="string">"max-statements"</span>: [<span class="number">1</span>, <span class="number">200</span>],</span><br><span class="line">        <span class="comment">// 强制每一行中所允许的最大语句数量</span></span><br><span class="line">        <span class="string">"max-statements-per-line"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求构造函数首字母大写 （要求调用 new 操作符时有首字母大小的函数，允许调用首字母大写的函数时没有 new 操作符。）</span></span><br><span class="line">        <span class="string">"new-cap"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"newIsCap"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="string">"capIsNew"</span>: <span class="literal">false</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 要求调用无参构造函数时有圆括号</span></span><br><span class="line">        <span class="string">"new-parens"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 要求或禁止 var 声明语句后有一行空行</span></span><br><span class="line">        <span class="string">"newline-after-var"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止使用 Array 构造函数</span></span><br><span class="line">        <span class="string">"no-array-constructor"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁用按位运算符</span></span><br><span class="line">        <span class="string">"no-bitwise"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求 return 语句之前有一空行</span></span><br><span class="line">        <span class="string">"newline-before-return"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求方法链中每个调用都有一个换行符</span></span><br><span class="line">        <span class="string">"newline-per-chained-call"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 禁用 continue 语句</span></span><br><span class="line">        <span class="string">"no-continue"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止在代码行后使用内联注释</span></span><br><span class="line">        <span class="string">"no-inline-comments"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止 if 作为唯一的语句出现在 else 语句中</span></span><br><span class="line">        <span class="string">"no-lonely-if"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止混合使用不同的操作符</span></span><br><span class="line">        <span class="string">"no-mixed-operators"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 不允许空格和 tab 混合缩进</span></span><br><span class="line">        <span class="string">"no-mixed-spaces-and-tabs"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许多个空行</span></span><br><span class="line">        <span class="string">"no-multiple-empty-lines"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"max"</span>: <span class="number">2</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 不允许否定的表达式</span></span><br><span class="line">        <span class="string">"no-negated-condition"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 不允许使用嵌套的三元表达式</span></span><br><span class="line">        <span class="string">"no-nested-ternary"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止使用 Object 的构造函数</span></span><br><span class="line">        <span class="string">"no-new-object"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止使用一元操作符 ++ 和 --</span></span><br><span class="line">        <span class="string">"no-plusplus"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止使用特定的语法</span></span><br><span class="line">        <span class="string">"no-restricted-syntax"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止 function 标识符和括号之间出现空格</span></span><br><span class="line">        <span class="string">"no-spaced-func"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许使用三元操作符</span></span><br><span class="line">        <span class="string">"no-ternary"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁用行尾空格</span></span><br><span class="line">        <span class="string">"no-trailing-spaces"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止标识符中有悬空下划线_bar</span></span><br><span class="line">        <span class="string">"no-underscore-dangle"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止可以在有更简单的可替代的表达式时使用三元操作符</span></span><br><span class="line">        <span class="string">"no-unneeded-ternary"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止属性前有空白</span></span><br><span class="line">        <span class="string">"no-whitespace-before-property"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制花括号内换行符的一致性</span></span><br><span class="line">        <span class="string">"object-curly-newline"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制在花括号中使用一致的空格</span></span><br><span class="line">        <span class="string">"object-curly-spacing"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制将对象的属性放在不同的行上</span></span><br><span class="line">        <span class="string">"object-property-newline"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制函数中的变量要么一起声明要么分开声明</span></span><br><span class="line">        <span class="string">"one-var"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"initialized"</span>: <span class="string">"never"</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 要求或禁止在 var 声明周围换行</span></span><br><span class="line">        <span class="string">"one-var-declaration-per-line"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求或禁止在可能的情况下要求使用简化的赋值操作符</span></span><br><span class="line">        <span class="string">"operator-assignment"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制操作符使用一致的换行符</span></span><br><span class="line">        <span class="string">"operator-linebreak"</span>: [<span class="number">2</span>, <span class="string">"after"</span>, &#123;</span><br><span class="line">            <span class="string">"overrides"</span>: &#123;</span><br><span class="line">                <span class="string">"?"</span>: <span class="string">"before"</span>,</span><br><span class="line">                <span class="string">":"</span>: <span class="string">"before"</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 要求或禁止块内填充</span></span><br><span class="line">        <span class="string">"padded-blocks"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求对象字面量属性名称用引号括起来</span></span><br><span class="line">        <span class="string">"quote-props"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制使用一致的反勾号、双引号或单引号</span></span><br><span class="line">        <span class="string">"quotes"</span>: [<span class="number">2</span>, <span class="string">"double"</span>, <span class="string">"avoid-escape"</span>],</span><br><span class="line">        <span class="comment">// 要求使用 JSDoc 注释</span></span><br><span class="line">        <span class="string">"require-jsdoc"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 要求或禁止使用分号而不是 ASI（这个才是控制行尾部分号的，）</span></span><br><span class="line">        <span class="string">"semi"</span>: [<span class="number">2</span>, <span class="string">"always"</span>],</span><br><span class="line">        <span class="comment">// 强制分号之前和之后使用一致的空格</span></span><br><span class="line">        <span class="string">"semi-spacing"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求同一个声明块中的变量按顺序排列</span></span><br><span class="line">        <span class="string">"sort-vars"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制在块之前使用一致的空格</span></span><br><span class="line">        <span class="string">"space-before-blocks"</span>: [<span class="number">2</span>, <span class="string">"always"</span>],</span><br><span class="line">        <span class="comment">// 强制在 function的左括号之前使用一致的空格</span></span><br><span class="line">        <span class="string">"space-before-function-paren"</span>: [<span class="number">0</span>, <span class="string">"always"</span>],</span><br><span class="line">        <span class="comment">// 强制在圆括号内使用一致的空格</span></span><br><span class="line">        <span class="string">"space-in-parens"</span>: [<span class="number">2</span>, <span class="string">"never"</span>],</span><br><span class="line">        <span class="comment">// 要求操作符周围有空格</span></span><br><span class="line">        <span class="string">"space-infix-ops"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 强制在一元操作符前后使用一致的空格</span></span><br><span class="line">        <span class="string">"space-unary-ops"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"words"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="string">"nonwords"</span>: <span class="literal">false</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 强制在注释中 // 或 /* 使用一致的空格</span></span><br><span class="line">        <span class="string">"spaced-comment"</span>: [<span class="number">2</span>, <span class="string">"always"</span>, &#123;</span><br><span class="line">            <span class="string">"markers"</span>: [<span class="string">"global"</span>, <span class="string">"globals"</span>, <span class="string">"eslint"</span>, <span class="string">"eslint-disable"</span>, <span class="string">"*package"</span>, <span class="string">"!"</span>]</span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 要求或禁止 Unicode BOM</span></span><br><span class="line">        <span class="string">"unicode-bom"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求正则表达式被括号括起来</span></span><br><span class="line">        <span class="string">"wrap-regex"</span>: <span class="number">0</span>,</span><br><span class="line"></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line">        <span class="comment">// ES6.相关 //</span></span><br><span class="line">        <span class="comment">//////////////</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">// 要求箭头函数体使用大括号</span></span><br><span class="line">        <span class="string">"arrow-body-style"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 要求箭头函数的参数使用圆括号</span></span><br><span class="line">        <span class="string">"arrow-parens"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="string">"arrow-spacing"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"before"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="string">"after"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 强制在子类构造函数中用super()调用父类构造函数，TypeScrip的编译器也会提示</span></span><br><span class="line">        <span class="string">"constructor-super"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制 generator 函数中 * 号周围使用一致的空格</span></span><br><span class="line">        <span class="string">"generator-star-spacing"</span>: [<span class="number">2</span>, &#123;</span><br><span class="line">            <span class="string">"before"</span>: <span class="literal">true</span>,</span><br><span class="line">            <span class="string">"after"</span>: <span class="literal">true</span></span><br><span class="line">        &#125;],</span><br><span class="line">        <span class="comment">// 禁止修改类声明的变量</span></span><br><span class="line">        <span class="string">"no-class-assign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许箭头功能，在那里他们可以混淆的比较</span></span><br><span class="line">        <span class="string">"no-confusing-arrow"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止修改 const 声明的变量</span></span><br><span class="line">        <span class="string">"no-const-assign"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止类成员中出现重复的名称</span></span><br><span class="line">        <span class="string">"no-dupe-class-members"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 不允许复制模块的进口</span></span><br><span class="line">        <span class="string">"no-duplicate-imports"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止 Symbol 的构造函数</span></span><br><span class="line">        <span class="string">"no-new-symbol"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 允许指定模块加载时的进口</span></span><br><span class="line">        <span class="string">"no-restricted-imports"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 禁止在构造函数中，在调用 super() 之前使用 this 或 super</span></span><br><span class="line">        <span class="string">"no-this-before-super"</span>: <span class="number">2</span>,</span><br><span class="line">        <span class="comment">// 禁止不必要的计算性能键对象的文字</span></span><br><span class="line">        <span class="string">"no-useless-computed-key"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求使用 let 或 const 而不是 var</span></span><br><span class="line">        <span class="string">"no-var"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求或禁止对象字面量中方法和属性使用简写语法</span></span><br><span class="line">        <span class="string">"object-shorthand"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求使用箭头函数作为回调</span></span><br><span class="line">        <span class="string">"prefer-arrow-callback"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求使用 const 声明那些声明后不再被修改的变量</span></span><br><span class="line">        <span class="string">"prefer-const"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求在合适的地方使用 Reflect 方法</span></span><br><span class="line">        <span class="string">"prefer-reflect"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求使用扩展运算符而非 .apply()</span></span><br><span class="line">        <span class="string">"prefer-spread"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求使用模板字面量而非字符串连接</span></span><br><span class="line">        <span class="string">"prefer-template"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// Suggest using the rest parameters instead of arguments</span></span><br><span class="line">        <span class="string">"prefer-rest-params"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求generator 函数内有 yield</span></span><br><span class="line">        <span class="string">"require-yield"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// enforce spacing between rest and spread operators and their expressions</span></span><br><span class="line">        <span class="string">"rest-spread-spacing"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 强制模块内的 import 排序</span></span><br><span class="line">        <span class="string">"sort-imports"</span>: <span class="number">0</span>,</span><br><span class="line">        <span class="comment">// 要求或禁止模板字符串中的嵌入表达式周围空格的使用</span></span><br><span class="line">        <span class="string">"template-curly-spacing"</span>: <span class="number">1</span>,</span><br><span class="line">        <span class="comment">// 强制在 yield* 表达式中 * 周围使用空格</span></span><br><span class="line">        <span class="string">"yield-star-spacing"</span>: <span class="number">2</span></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>关闭段落校验</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">/* eslint-disable */</span><br></pre></td></tr></table></figure>
<ul>
<li>关闭当前行校验</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">some code // eslint-disable-line</span><br></pre></td></tr></table></figure>
<ul>
<li>关闭下一行校验</li>
</ul>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">// eslint-disable-next-line</span><br><span class="line">some code</span><br></pre></td></tr></table></figure>

      </div>
    
  </div>

</article>

<button class="assist-btn2 circle" id="assist_btn2" title="点亮屏幕" style="left: 27px; top: 152px;">
  <i class="iconfont" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>
<button class="assist-btn1 circle" id="assist_btn1" title="关闭屏幕亮度" style="left: 27px; top: 152px;">
  <i class="iconfont toc-title" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>


<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>	

<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
  const btw = new BTWPlugin();
  btw.init({
    id: "container",
    blogId: "22699-1592137983091-414",
    name: "前端进阶之旅",
    qrcode: "https://poetries1.gitee.io/img-repo/2020/06/qrcode.jpg",
    keyword: "3a3b3c",
  });
</script>

<script type="text/javascript">

// white theme
var body = {color: "#555", background: "#000"};
var a_tag = {color: "#222"};
var header = { background: "#222"};
var logo_line_i = {background: "#222"};
// var post_code = {background: "#eee", color: "#222"};

function switch_theme() {
 $("body").css(body);
 $("a:not('.links-of-author-item a, .site-state-item a, .site-state-posts a, .feed-link a, .motion-element a, .post-tags a, .show-commit-cls a, #donate_board a')").css(a_tag);
 $(".header, .footer").css(header);
 $(".logo-line-before i, .logo-line-after i").css(logo_line_i);
 //$(".post code").css(post_code);
 $("#idhyt-surprise-ball #idhyt-surprise-ball-animation .drag").css(a_tag);
 $(".post-title-link, .posts-expand .post-meta, .post-comments-count, .disqus-comment-count, .post-category a, .post-nav-next a, .post-nav-item a").css(a_tag);
 
 // $("code").css({color: '#c5c8c6', background: '#1d1f21'});
 //$("#assist_btn1").hide(1500);
}

$(function () {
$("#assist_btn2").css("display","none");
 $("#assist_btn1").click(function() {
     switch_theme();
$("div#toc.toc-article").css({
 "background":"#eaeaea",
 "opacity":1
});
$(".toc-article ol").show();
$("#toc.toc-article .toc-title").css("color","#a98602");
$("#assist_btn1").css("display","none");
$("#assist_btn2").css("display","block");
 });
$("#assist_btn2").click(function() {
$("#assist_btn2").css("display","none");
$("#assist_btn1").css("display","block");
$("body").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
     $(".header, .footer").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
$(".toc-article ol").toggle(1000);
 });
});


//背景随机

var Y, O, E, L, B, C, T, z, N, S, A, I;
!function() {
var e = function() {
for (O.clearRect(0, 0, L, B), T = [{
x: 0,
y: .7 * B + C
}, {
x: 0,
y: .7 * B - C
}]; T[1].x < L + C;) t(T[0], T[1])
}, t = function(e, t) {
O.beginPath(), O.moveTo(e.x, e.y), O.lineTo(t.x, t.y);
var n = t.x + (2 * I() - .25) * C,
 r = a(t.y);
O.lineTo(n, r), O.closePath(), N -= S / -50, O.fillStyle = "#" + (127 * A(N) + 128 << 16 | 127 * A(N + S / 3) + 128 << 8 | 127 * A(N + S / 3 * 2) + 128).toString(16), O.fill(), T[0] = T[1], T[1] = {
 x: n,
 y: r
}
}, a = function n(e) {
var t = e + (2 * I() - 1.1) * C;
return t > B || t < 0 ? n(e) : t
};
Y = document.getElementById("evanyou"), O = Y.getContext("2d"), E = window.devicePixelRatio || 1, L = window.innerWidth, B = window.innerHeight, C = 90, z = Math, N = 0, S = 2 * z.PI, A = z.cos, I = z.random, Y.width = L * E, Y.height = B * E, O.scale(E, E), O.globalAlpha = .6, document.onclick = e, document.ontouchstart = e, e()
}()

   
$("#toc-eye").click(function(){
$("#toc.toc-article").toggle(1000);
});

</script>


   
  <div class="text-center donation">
    <div class="inner-donation">
      <span class="btn-donation">支持一下</span>
      <div class="donation-body">
        <div class="tip text-center">扫一扫，支持poetries</div>
        <ul>
        
          <li class="item">
            
              <span>微信扫一扫</span>
            
            <img src="/images/weixin.jpg" alt="">
          </li>
        
          <li class="item">
            
              <span>支付宝扫一扫</span>
            
            <img src="/images/zhifubao.jpg" alt="">
          </li>
        
        </ul>
      </div>
    </div>
  </div>


   
  <div class="box-prev-next clearfix">
    <a class="show pull-left" href="/2018/11/21/webpack-review/">
        <i class="icon icon-angle-left"></i>
    </a>
    <a class="show pull-right" href="/2018/11/23/webpack-dll/">
        <i class="icon icon-angle-right"></i>
    </a>
  </div>




</div>


  <a id="backTop" class="back-top">
    <i class="icon-angle-up"></i>
  </a>




  <div class="modal" id="modal">
  <span id="cover" class="cover hide"></span>
  <div id="modal-dialog" class="modal-dialog hide-dialog">
    <div class="modal-header">
      <span id="close" class="btn-close">关闭</span>
    </div>
    <hr>
    <div class="modal-body">
      <ul class="list-toolbox">
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/archives/"
              rel="noopener noreferrer"
              target="_self"
              >
              博客
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/categories/"
              rel="noopener noreferrer"
              target="_self"
              >
              分类
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/tags/"
              rel="noopener noreferrer"
              target="_self"
              >
              标签
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/search/"
              rel="noopener noreferrer"
              target="_self"
              >
              搜索
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/link/"
              rel="noopener noreferrer"
              target="_self"
              >
              友链
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/about/"
              rel="noopener noreferrer"
              target="_self"
              >
              关于
            </a>
          </li>
        
      </ul>

    </div>
  </div>
</div>



  
      <div class="fexo-comments comments-post">
    

    

    
    

    

    
    

    

<!-- Gitalk评论插件通用代码 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
  clientID: '5567a2c4abb858009d96',
  clientSecret: 'b9039ec056cf5c2346b3cdb63308a28c163f91e5',
  repo: 'poetries.github.io',
  owner: 'poetries',
  // 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
  // 50个字符串则会报错.
  // id: location.pathname.split('/').pop().substring(0, 49),
  id: location.pathname,
  admin: ['poetries'],
  // facebook-like distraction free mode
  distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
<!-- Gitalk代码结束 -->



  </div>

  

  <script type="text/javascript">
  function loadScript(url, callback) {
    var script = document.createElement('script')
    script.type = 'text/javascript';

    if (script.readyState) { //IE
      script.onreadystatechange = function() {
        if (script.readyState == 'loaded' ||
          script.readyState == 'complete') {
          script.onreadystatechange = null;
          callback();
        }
      };
    } else { //Others
      script.onload = function() {
        callback();
      };
    }

    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  window.onload = function() {
    loadScript('/js/bundle.js?235683', function() {
      // load success
    });
  }
</script>


  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
 
  
</body>
</html>
